import hashlib
import json
import re


from types import SimpleNamespace


class Namespace(SimpleNamespace):
    def __contains__(self, key):
        return hasattr(self, key)


def parse_json(text: str):
    return json.loads(text, object_hook=lambda d: Namespace(**d))


def hash(text: str):
    return hashlib.md5(text.encode("utf-8")).hexdigest()


def remove_brackets(string: str):
    return re.sub(r" ?\(.+\)", "", string).strip()
